import router from './router'

router.beforeEach((to, from, next) => {
    // 如果有token && profile 直接放行
    if (localStorage.getAccessToken()) {
        if (to.path === '/callback') {
            next("/");
        } else {
            next();
        }
    } else {
        //如果没有token信息
        if (to.path !== '/callback') {
            window.location.href = import.meta.env.VITE_ZC_API + "/doLogin?redirect_uri=" + window.location.origin + "/callback";
            return;
        }
        next();
    }
})
